package projectchumashgeniusproject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import projectchumashgeniusproject.ProjectChumashGeniusProject.BookName;

public class Book implements Serializable
{
    private BookName book;
    private List<Chapter> chapters;
    
    public Book(BookName b)
    {
        this(b, new ArrayList<Chapter>());
    }
    public Book(BookName b, ArrayList<Chapter> c)
    {
        this.book = b;
        this.chapters = new ArrayList<>(c);
    }
    public BookName getBook()
    {
        BookName bn = book;
        return bn;
    }
    public List<Chapter> getChapters()
    {
        return new ArrayList<>(chapters);
    }
    public void addChapter(Chapter c)
    {
        chapters.add(c.getChapterNumber() - 1, c);
    }
    public void addVerse(Verse v)
    {
        chapters.get(v.getChapterNumber() - 1).addVerse(v);
    }
    public void deleteVerse(int cn, int vn)
    {
        chapters.get(cn).deleteVerse(vn);
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 11 * hash + Objects.hashCode(this.book);
        hash = 11 * hash + Objects.hashCode(this.chapters);
        return hash;
    }
    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        
        final Book other = (Book) obj;
        
        if (this.book != other.book)
            return false;
        if (!Objects.equals(this.chapters, other.chapters))
            return false;
        
        return true;
    }
}